{% extends 'common/panel.html' %}
{% block title %}{{instance.name}}{% endblock title %}
{% block panel %}
    <h1>{{instance.name}}</h1>
    {% if instance.array %}
        <p>part of the <a class="myshapes-link" href="{{instance.array.get_absolute_url}}">{{instance.array.name}}</a> Array.</p>
    {% endif %}
    <div class="tabs">
        <ul>
            <li><a href="#Attributes"><span>Information</span></a></li>
            <li><a href="{% url mpa_habitat_representation instance.pk 'html' %}"><span>Representation</span></a></li>
            <li><a href="{% url mpa_replication instance.pk %}"><span>Replication</span></a></li>				
            <li><a href="#Groups"><span>Impact</span></a></li>
        </ul>
        <div id="Attributes">
            <ul class="metadata">
              {% if instance.user.first_name and instance.user.last_name %} 
                <li class="creator">Created By {{instance.user.first_name}} {{instance.user.last_name}}</li>
              {% else %}
                <li class="creator">Created By {{instance.user.username}}</li>
              {% endif %}
                <li class="created">Created {{instance.date_created|date:"d M, Y P"}}</li>
                <li class="modified">Modified {{instance.date_modified|date:"d M, Y P"}}</li>
                <br class="clear" />
            </ul>
            <h2>Total Area as Related to SAT Guidelines</h2>
            <p class="heading_subtext">The Science Advisory Team (SAT), has set guidelines for the size of MPA candidates. If this MPA does not meet those guidelines it may still be considered (especially if it is part of a larger cluster of MPAs). Your MPA has an area of <strong>{{ instance.area.sq_mi|floatformat:3 }} square miles</strong>.</p>
            {% load geographic_report %}
            {% geographic_report MLPA instance.geometry_final.area persist_mpa_geographic #Attributes %}
            <h2>Level of Protection</h2>
            {% if instance.lop %}
                <p>This MPA has been assigned a level of protection of <strong>{{instance.lop.name}}</strong> based on its designation and allowed uses.</p>
            {% else %}
                {% if not instance.designation %}
                    <p>This MPA <strong>has not been assigned a level of protection</strong> because you have not specified a designation.</p>
                {% else %}
                    {% if instance.other_allowed_uses %}
                        <p>This MPA <strong>has not been assigned a level of protection</strong> because you have specified allowed uses that have not yet been evaluated by the SAT.</p>
                    {% else %}
                        <p>This MPA <strong>has not been assigned a level of protection</strong>.</p>
                    {% endif %}
                {% endif %}
            {% endif %}
            {% if instance.sat_explanation %}
                <p>{{instance.sat_explanation}}</p>
            {% endif %}
            <h2>Regulations</h2>
            {% if instance.designation %}
            <div class="designation">
                <img style="background-color:{{instance.css_color}};" src="{{MEDIA_URL}}common/images/transparent.gif" width="18" height="33" />
                <div>
                    <h3>{{instance.designation.acronym}}, {{instance.designation.name}}</h3>
                    <a target="_blank" href="{{instance.designation.url}}">read more</a>                    
                </div>
                <br class="clear" />
            </div>
            {% else %}
                <p><strong>Designation not yet specified.</strong></p>
            {% endif %}
            <h3>Allowed Uses</h3>
            <table class="marinemap-table marinemap-table-zebra">
                <thead>
                    <tr>
                        <th scope="col">Target</th>
                        <th scope="col">Method</th>
                        <th scope="col">Use Type</th>
                    </tr>
                </thead>
                <tbody>
            {% if instance.allowed_uses.all %}
                {% for use in instance.allowed_uses.all %}
                    <tr>
                        <td class="pk" style="display:none;">
                            {{use.pk}}
                        </td>
                        <td class="target">
                            <span>{{use.target.name}}</span>
                        </td>
                        <td class="method">
                            <span>{{use.method.name}}</span>
                        </td>
                        <td class="purpose">
                            <span>{{use.purpose.name}}</span>
                        </td>
                    </tr>
                {% endfor %}
            {% else %}
                <tr class="none">
                    <td class="none" colspan="4">No allowed uses have been specified</td>
                </tr>
            {% endif %}
                </tbody>
            </table>
            {% if instance.other_allowed_uses %}
                <h3>Other Allowed Uses</h3>
                <p>{{instance.other_allowed_uses}}</p>
            {% endif %}
            {% if instance.other_regulated_activities %}
                <h3>Other Regulated Activities</h3>
                <p>{{instance.other_regulated_activities}}</p>
            {% endif %}
            <h2>Goals</h2>
            {% if instance.specific_objective or instance.design_considerations or instance.goal_objectives.all or instance.include_ncrsg_motion  %}
                {% if instance.specific_objective %}
                    <h3>Site-Specific Rational</h3>
                    <p>{{instance.specific_objective}}</p>
                {% else %}
                    <h3>MPA Rationale</h3>
                    <p><em>None specified.</em></p>
                {% endif %}
                {% if instance.design_considerations %}
                    <h3>Design Considerations</h3>
                    <p>{{instance.design_considerations}}</p>
                {% endif %}
                {% if instance.include_ncrsg_motion %}
                    <h3>NCRSG Motion</h3>
                    <p>The NCRSG proposes that the following language be included in the MPA regulations: <i>“All California Indian Tribal traditional, non-commercial fishing, gathering, and harvesting for subsistence, ceremonial or stewardship purposes shall be uses that are exercised by the members of California Indian tribes and tribal communities.”</i></p>
                {% endif %}
                {% if instance.goal_objectives.all %}
                    <h3>Goals and Regional Objectives</h3>
                    {% regroup instance.goal_objectives.all by goal_category as objectives_by_category %}
                    {% if objectives_by_category %}
                    
                   <ul class="goal_objectives">

                        {% for dict in objectives_by_category  %}
                            <li>
                            {% with dict.grouper as category %}
                                <h4>{{category.name}}</h4>
                                {{category.description}}
                                <ul>
                                    {% for objective in dict.list %}
                                        <li><label>{{objective.name}}</label><p>{{objective.description}}</p></li>
                                    {% endfor %}
                                </ul>

                            {% endwith %}
                            </li>
                        {% endfor %}        
                    </ul> 

                    <!-- <ul class="goal_objectives">
                        {% for dict in objectives_by_category  %}
                            {% for objective in dict.list %}
                                <li><label>{{objective.name}}</label><p>{{objective.description}}</p></li>
                            {% endfor %}
                        {% endfor %}        
                    </ul> -->

                    {% endif %}
                {% endif %}
            {% else %}
                <p><em>None specified</em></p>
            {% endif %}
            <h2>Other Information</h2>
            <p><strong>MPA ID:</strong> {{instance.pk}}</p>
            {% if instance.is_estuary or instance.boundary_description or instance.dfg_feasability_guidance or instance.evolution %}                
                {% if instance.is_estuary %}
                    <p>This is an <strong>Estuarine</strong> MPA</p>
                {% endif %}
                {% if instance.boundary_description %}
                    <h3>Boundary Description</h3>
                    <p>{{instance.boundary_description}}</p>
                {% endif %}
                {% if instance.dfg_feasability_guidance %}
                    <h3>DFG Feasibility Guidance</h3>
                    <p>{{instance.dfb_feasability_guidance}}</p>
                {% endif %}
                {% if request.user.is_staff %}
                    {% if instance.evolution %}
                        <h3>Staff Evolution Notes</h3>
                        <p>{{instance.evolution}}</p>
                    {% endif %}                    
                {% endif %}
            {% endif %}            
        </div>
        
        <div id="Groups" class="tabs">
            <ul>
                <li><a href="#Instructions"><span>Instructions</span></a></li>
                <li><a href="{% url mpa_impact_analysis instance.pk 'com' %}"><span>Commercial</span></a></li>
                <li><a href="{% url mpa_impact_analysis instance.pk 'cpfv' %}"><span>Commercial Private Fishing Vessel</span></a></li>
                <li><a href="{% url mpa_impact_analysis instance.pk 'div' %}"><span>Recreational Dive</span></a></li>
                <li><a href="{% url mpa_impact_analysis instance.pk 'kyk' %}"><span>Recreational Kayak</span></a></li>
                <li><a href="{% url mpa_impact_analysis instance.pk 'pvt' %}"><span>Recreational Vessel</span></a></li>
                <li><a href="{% url mpa_impact_analysis instance.pk 'swd' %}"><span>Edible Seaweed (Commercial)</span></a></li>
            </ul>
            <div id="Instructions">
                <h3>Impact Analysis Instructions</h3>
                <p>This page contains information on potential fishery-specific impacts for a single MPA within a proposal. Potential impacts associated with the MPA are presented as a summary across the entire North Coast Study Region. </p>
                <p>Potential impacts are summarized by port and by fishery.  Fron north to south, the ports are: Crescent City, Trinidad, Eureka - Arcata, Shelter Cove, Fort Brag, and Albion. </p>
                <p>The table output is organized into two columns: the percentage of the total value and the percentage of total area potentially impacted. </p>
                <p>A "---" (instead of a number value) means that potential impacts are not available for this fishery.  This occurs when 1) the fishery does not exist in the port, 2) insufficient data was collected in that port for that fishery, or 3) fewer than four fishermen were interviewed/participated in that fishery and to maintain confidentiality we are not reporting on that fishery.</p>
                <p>PLEASE BE AWARE: Selecting an MPA for analysis may require several minutes to execute.  Selecting other buttons within this panel while results are loading will cause unpredictable behavior within this panel.  If this is done accidentally, simply close out of the results panel, and then reselect your MPA. </p>
                <p>PLEASE NOTE: While the analytical methods are the same, the evaluation framework of MarineMap software varies slightly from the framework used by Ecotrust to prepare the Scientific Advisory Team (SAT) external evaluation. The primary difference is associated with how rounding occurs within each framework. Because of this, there may be minor differences in the values reported. For consistency, potential impacts to arrays should only be compared within the same framework. </p>
            </div>
        </div>        
    </div>
{% endblock panel %}
